﻿using System;

namespace _03_BridgeModel_Basic
{
    class Program
    {
        static void Main(string[] args)
        {
            Abstraction ab = new RefinedAbstractiion();
            ab.SetImlementor(new ConcreteImplementorA());
            ab.Operation();

            ab.SetImlementor(new ConcreteImplementorB());
            ab.Operation();

            Console.Read();
        }
    }

    // 实现类抽象
    abstract class Implementor
    {
        public abstract void Operation();
    }
    class ConcreteImplementorA : Implementor
    {
        public override void Operation()
        {
            Console.WriteLine("具体实现A的方法执行");
        }
    }
    class ConcreteImplementorB : Implementor
    {
        public override void Operation()
        {
            Console.WriteLine("具体实现B的方法执行");
        }
    }

    // 抽象
    class Abstraction
    {
        protected Implementor implementor;
        public void SetImlementor(Implementor implementor)
        {
            this.implementor = implementor;
        }
        public virtual void Operation()
        {
            implementor.Operation();
        }
    }

    class RefinedAbstractiion : Abstraction
    {
        public override void Operation()
        {
            implementor.Operation();
        }
    }


}
